package com.qt.service.oj.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.qt.exception.StatusFailException;
import com.qt.manager.oj.JudgeManager;
import com.qt.mapper.JudgeMapper;
import com.qt.mapper.ProblemMapper;
import com.qt.pojo.dto.SubmitJudgeDTO;
import com.qt.pojo.entity.judge.Judge;
import com.qt.pojo.vo.JudgeProblemResultVO;
import com.qt.result.R;
import com.qt.service.oj.JudgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author pgw
 * @version 1.0
 * @description
 * @date Create by 2023/9/24 14:01
 */
@Service
public class JudgeServiceImpl extends ServiceImpl<JudgeMapper , Judge>  implements JudgeService  {

    @Autowired
    private JudgeMapper judgeMapper;

    @Autowired
    private JudgeManager judgeManager;

    @Autowired
    private ProblemMapper problemMapper;



    @Override
    public List<JudgeProblemResultVO> getJudgeProblemStatus(List<Long> problemIds) {
        return judgeMapper.getJudgeProblemResult(problemIds);
    }


    @Override
    public R submitProblemJudge(SubmitJudgeDTO submitJudgeDto) {

        try {
            return R.success(judgeManager.submitProblemJudge(submitJudgeDto));
        } catch (StatusFailException e) {
            throw new RuntimeException(e);
        }

    }


}
